<template>
	<view class="tabberbig">
		<view class="tabber">
			<view class="tab" v-for="(item,index) in list" :key="index" @click="qh(item.pagePath)">
				<image v-if=' item.pagePath === cureentPage ' :src="item.selectedIconPath" mode=""></image>
				<image v-else :src="item.iconPath" mode=""></image>
				<view class="text f-color" :class="{'active':item.pagePath === cureentPage}">{{item.text}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	// 引入wxjs
	// import wx from "weixin-js-sdk";
	// import $api from '../../common/api/request3.js'

	export default {
		props: {
			cureentPage: {
				type: String,
				default: "index"
			}
		},
		data() {
			return {
				list: [{
						"pagePath": "index",
						"iconPath": "/static/syqt/sy.png", //未选中的图标
						"selectedIconPath": "/static/syqt/syy.png", //已选中的图标
						"text": "发现"
					},
					// {
					// 	"pagePath": "coupon1",
					// 	"iconPath": "/static/syqt/xi.png",
					// 	"selectedIconPath": "/static/syqt/xii.png",
					// 	"text": "消息"
					// },
					// {
					// 	"pagePath": "lianxi",
					// 	"iconPath": "/static/syqt/fb.png",
					// 	"selectedIconPath": "/static/syqt/fbb.png",
					// 	"text": "小店"
					// },
					// {
					// 	"pagePath": "order1",
					// 	"iconPath": "/static/syqt/fa.png",
					// 	"selectedIconPath": "/static/syqt/faa.png",
					// 	"text": "跑腿"
					// },
					{
						"pagePath": "my",
						"iconPath": "/static/syqt/wo.png",
						"selectedIconPath": "/static/syqt/woo.png",
						"text": "我的"
					}
				],
				appId: '',
				nonceStr: '',
				signature: '',
				timestamp: '',
				username: '',
				kf_url: ''

			}
		},
		onLoad() {},
		methods: {
			async djk() {
				var url = encodeURIComponent(window.location.href);
				var ua = navigator.userAgent.toLowerCase();
				if (ua.match(/MicroMessenger/i) == "micromessenger") {
					this.username = uni.getStorageSync('openid');
					this.from = 2
				} else {
					let userInfo = await this.$getH5UserInfo();
					this.username = userInfo.id;
					this.from = 1
				}
				// 正确数据
				$api.request({
					url: "kaquan/getGoods",
					method: 'POST',
					data: {
						username: this.username
					}
				}).then((res) => {
					console.log(res.kf_url)
					this.kf_url = res.kf_url

					uni.hideLoading();
				}).catch(() => {
					uni.hideLoading();
					uni.showToast({
						title: "请求失败",
						icon: "none"
					})
				})
			},
			qh(e) {
				if (e === "share") {
					this.djk()
					let then = this
					setTimeout(() => {
						console.log('88888', this.kf_url); //obj
						window.location.href=this.kf_url;
					}, 500)



				} else {
					// 跳转页面
					uni.redirectTo({
						url: `/pages/${e}/${e}`
					})
				}
			},
			getShareInfo() {

			},


		}
	}
</script>

<style lang="scss" scoped>
	.tabberbig{
		background-color: #ffffff;
		z-index: 999;
		position: fixed; //定位
		left: 0;
		bottom: 0;
		width: 100%;
		height: 200rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		
	}
	.tabber {
		background-color: #ffffff;
		z-index: 9999;
		border-radius: 50rpx;
		position: fixed; //定位
		left: 50%;
		transform: translateX(-50%);
		width: 90%;
		height: 110rpx;
		display: flex;
		justify-content: space-around; //一字排开
		align-items: center;
		/* border-top: 1rpx solid #d6ecf0; */
		box-shadow: 0 0 1px 1px #f0fcff, 0 0 1px 1px #f3f9f1, 0 0 8px 2px #e0eee8;

	}

	image {
		width: 47rpx;
		height: 47rpx;
		position: relative; //相对定位
	}

	.text {
		position: relative; //相对定位
		padding: 5rpx 0;
		font-size: 22rpx;
		&.active {
			color: #25B8A4;
		}
	}

	.tab {
		display: flex;
		flex-direction: column; //保持上下结构
		justify-content: center;
		align-items: center;
	}

	/* 11111111111111111111 */
	/* 	.tabber{
	    border-top:2rpx solid #636263;
	    background-color: #FFFFFF;
	    z-index: 9999;
	    position: fixed;
	    left:0;
	    bottom:0;
	    width:100%;
	    height: 120rpx;
	    display: flex;
	    justify-content: space-around;
	    align-items: center;
	}
	
	image{
	    width: 40rpx;
	    height: 40rpx;
	}
	.text{
	    padding:10rpx 0;
	    font-size:24rpx;
	}
	.tab{
	    display: flex;
	    flex-direction: column;
	    justify-content: center;
	    align-items: center;
	} */
</style>